package com.iweb.service.impl;

import com.iweb.dao.CategoryDao;
import com.iweb.dao.impl.CategoryDaoImpl;
import com.iweb.entity.Category;
import com.iweb.service.CategoryService;
import com.iweb.util.Pager;

import java.util.List;

/**
 * @author jay
 * @date 2021/9/11
 * @desc
 */
public class CategoryServiceImpl implements CategoryService {
    private CategoryDao categoryDao = new CategoryDaoImpl();

    @Override
    public List<Category> findPagedList(Pager<Category> pager) throws Exception {
        return this.categoryDao.selectPagedList(pager);
    }

    @Override
    public int findTotalRows() throws Exception {
        return this.categoryDao.selectTotalCount();
    }

    @Override
    public List<Category> findList() throws Exception {
        return this.categoryDao.selectList();
    }

    @Override
    public List<Category> findList(Integer parentId) throws Exception {
        return this.categoryDao.selectList(parentId);
    }

    @Override
    public Category findById(Integer id) throws Exception {
        return this.categoryDao.selectCategoryById(id);
    }

    @Override
    public boolean remove(Integer id) throws Exception {
        return this.categoryDao.delete(id) > 0;
    }

    @Override
    public void add(Category category) throws Exception {
        this.categoryDao.insert(category);
    }

    @Override
    public boolean modify(Category category) throws Exception {
        return this.categoryDao.update(category) > 0;
    }
}
